package com.gotop.system.wrapper;

import com.gotop.common.utils.ApplicationStringUtils;
import com.gotop.common.utils.support.BeanUtil;
import com.gotop.entity.system.Post;
import com.gotop.system.service.system.IDictService;
import com.gotop.vo.system.PostVO;

import java.util.Objects;

/**
 * @program: cem
 * @description:
 * @author: superfish
 * @create: 2020-12-25 15:16
 **/
public class PostWrapper extends BaseEntityWrapper<Post, PostVO> {

    private static IDictService dictService;

    static {
        dictService = ApplicationStringUtils.getBean(IDictService.class);
    }

    public static PostWrapper build() {
        return new PostWrapper();
    }

    @Override
    public PostVO entityVO(Post post) {
        PostVO postVO = Objects.requireNonNull(BeanUtil.copy(post, PostVO.class));
        String categoryName = dictService.getValue("post_category", post.getCategory());
        postVO.setCategoryName(categoryName);
        return postVO;
    }

}
